package com.ww.springboot.springstudy.listener;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-06-25 17:34
 */
@Component
public class ListenerDemo {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(ListenerDemo.class);

        context.refresh();

        context.close();
    }

    @Component
    static class EventListener {

        @org.springframework.context.event.EventListener
        public void listener(ContextRefreshedEvent contextRefreshedEvent) {
            System.out.println("事件：" + contextRefreshedEvent);
        }
    }
}
